package com.yy.tech.inte.service.intercepter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 请求拦截后构建一个Response
 * technical-identification$
 *
 * @author YY
 * @version 1.0.0
 * @date $ $
 * @description: TODO
 */
public interface RequestInterceptor {

    Object response(Class clz);

    @Component
    public static class Impl implements RequestInterceptor{
        private Logger logger = LoggerFactory.getLogger(getClass());
        @Override
        public Object response(final Class clz) {
            if (null !=clz && clz != Void.class){
                try {
                    return clz.newInstance();
                } catch (Exception e) {
                    logger.warn(">> Create response[%s] exception :{}",clz.getName(),e.getMessage());
                }
            }
            return null;
        }
    }
}
